var sys = require('sys');
var game = require('./game');

exports.create = function() {
  return new GamePool();
}

function GamePool() {
  this.gamePool = [];
  
  sys.log("GamePool:construct Creating new GamePool");

  this.contains = function(id) {
    return (this.get(id));
  }
  
  this.get = function(id) {
    for(var i = 0; i < this.gamePool.length; i++)
    {
      if(this.gamePool[i].contains(id))
        return this.gamePool[i];
    }
    
    return null;
  }
  
  this.createFrom = function(queue) {
    var newGame = game.create();
    for(var i = 0; i < queue.size(); i++)
      newGame.add(queue.playerList[i]);
      
    this.gamePool.push(newGame);
  }
}